package com.zyx.controller;

import com.zyx.pojo.User;
import com.zyx.service.UserService;
import com.zyx.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@CrossOrigin//允许跨域
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("login")
    public Result login(@RequestBody User user){
        return userService.login(user);
    }

    @GetMapping("getUserInfo")
    public Result getUserInfo(@RequestHeader String token){
        return userService.getUserInfo(token);
    }

    @PostMapping("checkUserName")
    public Result checkUserName(String username){
        Result result = userService.checkUserName(username);
        return result;
    }

    @PostMapping("regist")
    public Result regist(@RequestBody User user){
        return userService.regist(user);
    }

    @GetMapping("checkLogin")
    public  Result CheckLogin(@RequestHeader String token){
        return userService.checkLogin(token);
    }
}
